package cc.linker.steplink.crm.merchant.task;

import cc.linker.steplink.crm.commons.lock.RedisLock;
import cc.linker.steplink.crm.merchant.dao.acs.XbMerchantMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
public class AcsAccountTask {

    @Autowired
    private XbMerchantMapper xbMerchantMapper;

    /**
     * 每天0点记录大b、小b余额
     */
    @RedisLock("AcsAccountTask_balance")
    @Scheduled(cron = "1 0 0 * * ?")
    public void balance() {
        List<Map<String, Object>> balanceEachOrg = xbMerchantMapper.getBalanceEachOrg();
        List<Map<String, Object>> balanceEachSales = xbMerchantMapper.getBalanceEachSales();
        balanceEachOrg.addAll(balanceEachSales);
        xbMerchantMapper.insertBatchOrgBalance(balanceEachOrg);
    }
}
